<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数组</title>
</head>
<body>
    <div>
        <img id="par">
    </div>
        <script>
            //var a=['1','2','3','4']
           // console.log(a)


          /* var b = new Array('ton','tom','ome');
            console.log(b[2]);
            console.log(b[0]);
            console.log(b[1])*/


          var par =document.getElementById('par');      //获取它的图片

          var img =[                                    //建立一个数组
              'img/1.jpg',
                'img/2.jpg',
                'img/3.jpg',
                'img/4.jpg',
                'img/5.jpg'
          ];
          var h = Math.random()*5;                      //0-1之间的随机数
          h = Math.floor(h);                            //四舍五入留整数
            console.log(h);                         //打印值
            par.src=img[h];                          //<img src=h>
        </script>



</body>
</html>